import { _decorator, Component, Animation, Label } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('msgToast')

export class msgToast extends Component {
    animation: Animation = null;

    start() {
        this.animation = this.getComponent(Animation)
        this.animation.on(Animation.EventType.STOP, this.onAnimationStop, this);
    }
    showToast(conent: string) {
        let l = this.getComponentInChildren(Label)
        l.string = conent
    }
    onAnimationStop() {
        this.animation = null;
        this.node.destroy();//直接销毁节点，最具有效率的方式
        this.node.removeFromParent();//移除与父节点的引用
    }

}


